<?php

$db = new PDO('mysql:host=localhost; dbname=db3', 'root', '12qwas');
//$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE,PDO::FETCH_ASSOC);
$ps = $db->query('select * from students limit 1');
//$rs=$ps->fetchAll(PDO::FETCH_ASSOC);//得到的是一个数组
//print_r($rs);
//$ps = $db->query('select * from students limit 1', PDO::FETCH_ASSOC);
//print_r($ps->fetch());

//$ps = $db->prepare('select * from students where xh=?');
//$ps->setFetchMode(PDO::FETCH_ASSOC);
//$ps->execute(['233110201']);
//print_r($ps->fetch());

$ps = $db->prepare('select * from students where xh=?');
$ps->execute(['233110201']);
print_r($ps->fetch(PDO::FETCH_ASSOC));
